<?php

use think\migration\Seeder;

class SourceWeatherRealtimeData extends Seeder
{
    /**
     * 中国天气网数据
     */
    public function run()
    {
        $table = $this->table('source_weather_com_cn_weather_realtime');
        $rows = [
            [
                'region_id'      => '101100501',
                'city'         => '长治',
                'data'         => $this->data(),
                'publish_time' => date('Y-m-d H', time()) . ':00:00',
                'create_time'  => date('Y-m-d H:i:s', time()),
            ],
        ];
        $table->insert($rows)->save();
    }

    public function data()
    {
        $data = file_get_contents(__DIR__ . '/json/weather_com_cn.json');
        return $data;
    }
}
